﻿using MSSQL.PagingCorrelation;
using System.Collections.Generic;

namespace MSSQL.Interface
{ /// <summary>
  /// 数据查询接口，该接口提供了查询的基本定义
  /// </summary>
	public interface IDataQuery
	{
		/// <summary>
		/// 设置该查询用例使用的库
		/// </summary>
		string DataBaseName { set; }

        /// <summary>
        /// 单条查询
        /// </summary>
        /// <typeparam name="T">查询结果类型</typeparam>
        /// <param name="sqlCommand">sql命令</param>
        /// <param name="parameter">查询参数</param>
        /// <returns>查询结果</returns>
        T QuerySingleData<T>(string sqlCommand, object parameter);


        /// <summary>
        /// 根据code获取单条信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="gCode"></param>
        /// <returns></returns>
        T QuerySingleByCode<T>(string gCode);

        /// <summary>
        /// 单条查询,传递条件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sWhere"></param>
        /// <param name="parameter"></param>
        /// <returns></returns>
        T QuerySingleByWhere<T>(string sWhere, object parameter);


        ///// <summary>
        ///// 多条获取
        ///// </summary>
        ///// <typeparam name="T"></typeparam>
        ///// <param name="parameter">查询参数</param>
        ///// <returns>查询结果</returns>
        //IList<T> QueryListData<T>(object parameter);

        /// <summary>
        /// 多条查询
        /// </summary>
        /// <typeparam name="T">泛型类型</typeparam>
        /// <param name="sqlCommand">sql命令</param>
        /// <param name="parameter">查询参数</param>
        /// <returns>查询结果</returns>
        IList<T> QueryListData<T>(string sqlCommand, object parameter);

        /// <summary>
        /// 分页查询数据
        /// </summary>
        /// <typeparam name="T">查询结果的类型</typeparam>
        /// <param name="pageInfo">分页条件</param>
        /// <param name="sqlCommand">sql语句</param>
        /// <param name="parameter">参数</param>
        /// <returns>分页结果对象</returns>
        PagingResult<T> QueryPaginationData<T>(PageInfo pageInfo, string sqlCommand, object parameter);
	}
}
